package com.aos.erp.message.dto;

import com.aos.erp.message.enums.DelStatus;
import com.aos.erp.message.enums.PushType;
import com.aos.erp.message.model.MTDriverSchoolInfo;
import com.aos.erp.message.model.MessageTemplateInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ApiModel("模板详情")
public class MessageTemplateItemDTO implements Serializable {
    @ApiModelProperty(value="模板ID",hidden=true)
    private long id = 0;
    @ApiModelProperty(value="模板编号",hidden=true)
    private String mtCode = ""; // 编号
    @ApiModelProperty(value="模板标题",hidden=true)
    private String mtTitle = "";    // 标题
    @ApiModelProperty(value="推送方式",hidden=true)
    private String pushType = "";
    @ApiModelProperty("是否删除：del_no为未删除；del_yes为已删除")
    private DelStatus isDel = DelStatus.del_no;
    @ApiModelProperty(value="创建人",hidden=true)
    private String createUser = ""; // 创建人
    @ApiModelProperty(value="创建时间",hidden=true)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;    //创建时间
    @ApiModelProperty(value="修改人",hidden=true)
    private String updateUser = ""; // 修改人
    @ApiModelProperty(value="修改时间",hidden=true)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;    //修改时间

    public String getPushType() {
        String[] pushTypeArr = pushType.split(",");
        List<String> pushTypeList = new ArrayList<>();
        for (String type : pushTypeArr) {
            if(!pushTypeList.contains(type)) {
                pushTypeList.add(type);
            }
        }


        String pushTypeName = "";
        for (String type : pushTypeList) {
            if(!pushTypeName.isEmpty()) {
                pushTypeName += ",";
            }
            pushTypeName += PushType.getDesc(type);
        }
        return pushTypeName;
    }
}
